﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using SmarterCharger.Library.Infrastructure;
using SmarterCharger.Library.Model;
using SmarterCharger.Library.Repositories;
using SmarterCharger.Library.Repositories.Interfaces;
using SmarterCharger.Library.Tests.Unit.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace SmarterCharger.Library.Tests.Integration.SmartPlugRepositorySpecifications
{
    public abstract class WhenSwitchSmartPlug : TestBaseAsync<HttpResponseResult>
    {
        protected ISmartPlugRepository SmartPlugRepository { get; private set; }
        public virtual SwitchSmartPlugRequest request 
        {
            get
            {
                return new SwitchSmartPlugRequest
                {
                    Username = TestAccount.Username,
                    Password = TestAccount.Password,
                    SmartPlugId = TestAccount.EnergyDeviceId,
                    IsOn = true
                };
            }
        }

        protected override void Arrange()
        {
            SmartPlugRepository = new SmartPlugRepository();
        }

        protected override Task<HttpResponseResult> Act()
        {
            return SmartPlugRepository.SwitchSmartPlug(request);
        }
    }

    [TestClass]
    public class WhenGetEnergyDevicesGivenUsernameAndPasswordValid : WhenSwitchSmartPlug
    {
        [TestMethod]
        public void ThenResultShouldBeNoContent()
        {
            Assert.IsNotNull(Result);
            Assert.AreEqual(HttpStatusCode.NoContent, Result.StatusCode);
        }
    }
}
